package com.gxa.p2p.service.impl;

import com.gxa.p2p.mapper.RepaymentRecordMapper;
import com.gxa.p2p.pojo.RepaymentRecord;
import com.gxa.p2p.service.RepaymentRecordService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @author BKP
 * @date 2020.8.10
 */
@Service("repaymentRecordService")
@Transactional(readOnly = true, propagation = Propagation.SUPPORTS, isolation = Isolation.DEFAULT)
public class RepaymentRecordServiceImpl implements RepaymentRecordService {

    @Resource
    RepaymentRecordMapper repaymentRecordMapper;

    /**
     * 带条件分页查询接口
     * @param map
     * @return List
     */
    @Override
    public List<RepaymentRecord> findAll(Map<String,Object> map) {
        int page = ((Integer) map.get("page") - 1) * (Integer) map.get("limit");
        map.put("page",page);
        return repaymentRecordMapper.findAll(map);
    }

    /**
     * 计算带条件的数据总数
     * @param map
     * @return Integer
     */
    @Override
    public Integer dataSum(Map<String,Object> map) {
        return repaymentRecordMapper.dataSum(map);
    }
}
